class ReposForks
  attr_accessor :github

  def initialize(github)
    @github = github
  end

  def listForks(repo, sort=nil, user=nil)
    username = user == nil ? @github.username : user
    url = 'repos/%s/%s/forks' % [username, repo]
    if sort
      url = '%s?%s=%s' % ['sort', sort]
    end
    @github.get(url)
  end

  def createFork(repo, org=nil, user=nil)
    username = user == nil ? @github.username : user
    url = 'repos/%s/%s/forks' % [username, repo]
    if org
      url = '%s?%s=%s' % [url, 'org', org]
    end
    @github.post(url)
  end
end